package com.demo.springboot;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.stereotype.Component;

/***
 * BeanFactoryPostProcessor 在Spring容器初始化之后触发，而且仅触发一次
 * 触发时机要比BeanPostProcessor早
 */
@Component
public class MyBeanFactoryPostProcessor implements BeanFactoryPostProcessor {


    @Override
    public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
        System.out.println("------容器中的Bean的数量：------"+beanFactory.getBeanDefinitionCount());
    }
}
